package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.entity.VO.T09VO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T09;
import com.ruoyi.service.YYDIT09Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 知识库Controller
 *
 * @author ruoyi
 * @date 2024-07-27
 */
@RestController
@RequestMapping("/T09/T09")
public class YYDT09Controller extends BaseController
{
    @Autowired
    private YYDIT09Service t09Service;

    /**
     * 查询知识库列表
     */
    @PreAuthorize("@ss.hasPermi('T09:T09:list')")
    @GetMapping("/list")
    public TableDataInfo list(T09 t09)
    {
        startPage();
        List<T09VO> list = t09Service.selectT12V0List(t09);;
        return getDataTable(list);
    }

    /**
     * 导出知识库列表
     */
    @PreAuthorize("@ss.hasPermi('T09:T09:export')")
    @Log(title = "知识库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, T09 t09)
    {
        List<T09> list = t09Service.selectT09List(t09);
        ExcelUtil<T09> util = new ExcelUtil<T09>(T09.class);
        util.exportExcel(response, list, "知识库数据");
    }

    /**
     * 获取知识库详细信息
     */
    @PreAuthorize("@ss.hasPermi('T09:T09:query')")
    @GetMapping(value = "/{F0901}")
    public AjaxResult getInfo(@PathVariable("F0901") Long F0901)
    {
        return success(t09Service.selectT09ByF0901(F0901));
    }

    /**
     * 新增知识库
     */
    @PreAuthorize("@ss.hasPermi('T09:T09:add')")
    @Log(title = "知识库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody T09 t09)
    {
        return toAjax(t09Service.insertT09(t09));
    }

    /**
     * 修改知识库
     */
    @PreAuthorize("@ss.hasPermi('T09:T09:edit')")
    @Log(title = "知识库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody T09 t09)
    {
        return toAjax(t09Service.updateT09(t09));
    }

    /**
     * 删除知识库
     */
    @PreAuthorize("@ss.hasPermi('T09:T09:remove')")
    @Log(title = "知识库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{F0901s}")
    public AjaxResult remove(@PathVariable Long[] F0901s)
    {
        return toAjax(t09Service.deleteT09ByF0901s(F0901s));
    }
}
